<template>
  <ul class="menus">
    <li v-for="item in menus" :key="item.title">
      <a :href="`#${item.id}`">#{{ item.title }}</a>
      <ul v-if="item[childLabel]" class="child">
        <menu-tree
          :menus="item[childLabel]"
          :child-label="childLabel"
        ></menu-tree>
      </ul>
    </li>
  </ul>
</template>

<script lang="ts">
import { defineComponent } from "vue";

export default defineComponent({
  name: "menuTree",
  props: {
    menus: {
      type: [Object, Array],
      required: true,
    },
    childLabel: {
      type: String,
      default: "child",
    },
  },
});
</script>

<style lang="less" scoped>
    .menus{
        line-height: 1.7em;
    }
    .child{
        padding-left: 15px;
    }
</style>